package fxTrader.retriever;


import java.util.ArrayList;

import updater.currency.convertor.ReadRSS;
import updater.currency.data.Currency;

public class CurrencyRetriever {

	public static ArrayList<Currency> getCurrencyListBySymbol(String symbol) {

		ReadRSS readRSS = new ReadRSS();
		ArrayList<Currency> currencyList = readRSS.ReadCurrencyFromXML(symbol);
		return currencyList;
	}

	public static ArrayList<Currency> getCurrencyListBySymbolAndLatestDays(
			String symbol, int latestDays) {

		ReadRSS readRSS = new ReadRSS();
		ArrayList<Currency> currencyList = readRSS.ReadCurrencyFromXML(symbol);
		int size = currencyList.size();
		if (latestDays > size) {
			return currencyList;
		}
		ArrayList<Currency> currencyListWithinDays = new ArrayList<Currency>();
		int startIndex = size -latestDays ;
		System.out.println("start_index"+startIndex + "count"+size);
		for (int i = startIndex; i < currencyList.size(); i++) {
			currencyListWithinDays.add(currencyList.get(i));
		}

		return currencyListWithinDays;

	}
	
	public static Currency getLatestCurrencyBySymbol(
			String symbol) {

		ReadRSS readRSS = new ReadRSS();
		ArrayList<Currency> currencyList = readRSS.ReadCurrencyFromXML(symbol);
		int size = currencyList.size();
		return currencyList.get(currencyList.size()-1);

	}
	

}
